const express = require('express');
const router = express.Router();
const retUtil = require('../util/retUtil');
const usersUtil = require('./util/usersUtil');
const financialService = require('../../../service/financialService');

router.get('/ck', function(req, res, next) {
    res.json({'ok':':)'});
});

/*
* 根据提现记录自动打款
*
* @author 王俊
* @date 2018-07-20
*
* 参数: financeId 提现记录 id
* 参数: userId 操作人员 id
*
* */
function remitFinance(req, res, next) {

    const financeId = retUtil.numberFromReq(req, 'financeId');
    const userId = retUtil.numberFromReq(req, 'userId');

    const opt = {
        hisId: financeId,
        userId: userId
    };
    financialService.transferToUserWithFinanceHis(opt, function (error, data) {
        if(error) return retUtil.ret_err_json(error, res);
        return retUtil.ret_succ_json(data, res);
    })

}
router.get('/remitFinance', remitFinance);
router.post('/remitFinance', remitFinance);



module.exports = router;
